//监听对象属性
function Observer(target, fn){
  if(typeof target !=='object' || target === null) {
    return target
  }
  for(let key in target) {
    DefineReactive(target,key,target[key], fn)
  }
}
function DefineReactive (target, key, value, fn){
    Observer(value)
  Object.defineProperty(target,key,{
    get(){
      return value
    },
    set(newValue){
      if(newValue !== value) {
        Observer(newValue)
        value = newValue
        if (typeof(fn) === 'function') {
            fn()
        }
      }
    }
  })
}
exports.observer = Observer
